package mall.controller;

import mall.pojo.Orders;
import mall.service.OrderDetailService;
import mall.service.OrderService;
import mall.util.UtilityClass;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

@Controller
public class OrderDetailController {

	@Autowired
	private OrderDetailService orderDetailService;
	@Autowired
	private OrderService orderService;

	@RequestMapping(value = "/orderdetail", method = RequestMethod.GET)
	public ModelAndView orderDetail(@RequestParam("id") int orderId) {
		ModelAndView modelAndView = new ModelAndView();
		modelAndView.addObject("order", orderService.getOrder(orderId));
		modelAndView.addObject("orderdetail",
				orderDetailService.getOrderDetailShop(orderId));
		modelAndView.setViewName(UtilityClass.VIEW_SHOP_ORDERDETAIl_ADMIN);
		return modelAndView;
	}
}
